package com.ruoyi.finance.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.finance.domain.WProductSalesInfo;
import com.ruoyi.finance.service.IWProductSalesInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 开票商品Controller
 * 
 * @author ruoyi
 * @date 2025-03-05
 */
@RestController
@RequestMapping("/WProductSalesInfo")
public class WProductSalesInfoController extends BaseController
{
    @Autowired
    private IWProductSalesInfoService wProductSalesInfoService;

    /**
     * 查询开票商品列表
     */
    @RequiresPermissions("finance:WProductSalesInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(WProductSalesInfo wProductSalesInfo)
    {
        startPage();
        List<WProductSalesInfo> list = wProductSalesInfoService.selectWProductSalesInfoList(wProductSalesInfo);
        return getDataTable(list);
    }

    /**
     * 导出开票商品列表
     */
    @RequiresPermissions("finance:WProductSalesInfo:export")
    @Log(title = "开票商品", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WProductSalesInfo wProductSalesInfo)
    {
        List<WProductSalesInfo> list = wProductSalesInfoService.selectWProductSalesInfoList(wProductSalesInfo);
        ExcelUtil<WProductSalesInfo> util = new ExcelUtil<WProductSalesInfo>(WProductSalesInfo.class);
        util.exportExcel(response, list, "开票商品数据");
    }

    /**
     * 获取开票商品详细信息
     */
    @RequiresPermissions("finance:WProductSalesInfo:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wProductSalesInfoService.selectWProductSalesInfoById(id));
    }

    /**
     * 新增开票商品
     */
    @RequiresPermissions("finance:WProductSalesInfo:add")
    @Log(title = "开票商品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WProductSalesInfo wProductSalesInfo)
    {
        return toAjax(wProductSalesInfoService.insertWProductSalesInfo(wProductSalesInfo));
    }

    /**
     * 修改开票商品
     */
    @RequiresPermissions("finance:WProductSalesInfo:edit")
    @Log(title = "开票商品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WProductSalesInfo wProductSalesInfo)
    {
        return toAjax(wProductSalesInfoService.updateWProductSalesInfo(wProductSalesInfo));
    }

    /**
     * 删除开票商品
     */
    @RequiresPermissions("finance:WProductSalesInfo:remove")
    @Log(title = "开票商品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wProductSalesInfoService.deleteWProductSalesInfoByIds(ids));
    }
}
